package com.deyang.share.dao;

import java.util.List;

import com.deyang.share.common.dao.BaseDao;
import com.deyang.share.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository("userDao")
public class UserDaoImpl implements UserDao {
    @Autowired
	private BaseDao baseDao;
	
	public BaseDao getBaseDao() {
		return baseDao;
	}

	public void setBaseDao(BaseDao baseDao) {
		this.baseDao = baseDao;
	}

	@Override
	public void addUser(User user) {
        baseDao.save(user);
	}

	@Override
	public void deleteUser(User user) {
		baseDao.delete(user);
	}

	@Override
	public void deleteUserById(Long id) {
		baseDao.delete(User.class,id);
	}

	@Override
	public List<User> getAllUser() {
		return (List<User>)baseDao.find("from User");
	}

	@Override
	public User getUserById(Long id) {
		return baseDao.get(User.class,id);
	}

	@Override
	public void updateUser(User user) {
        baseDao.update(user);
	}

}
